package com.foreverwin.jzymes.common.util;

import com.foreverwin.jzymes.framework.util.DateUtil;
import com.foreverwin.jzymes.framework.util.I18nUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

import java.util.Date;
import java.util.UUID;

/**
 * BOHandle 处理工具类
 *
 * @author ervin
 * @date 2019-03-13
 */
public class BOHandleUtil {


    /**
     * 获取站点Handle
     *
     * @param site
     * @return
     */
    public static String buildSiteHandle( String site ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));

        return "SiteBO:" + site;
    }

    /**
     * 获取主数据字段组Handle
     *
     * @param site
     * @param fieldName
     * @return
     */
    public static String buildFieldGroupHandle( String site, String fieldName ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( fieldName, I18nUtil.getI18nText( "common.fieldNameNotBlank" ));

        return "FieldBO:" + site + "," + fieldName;
    }

    /**
     * 拆分主数据字段组Handle
     *
     * @param fieldGroupBo
     * @return
     */
    public static String[] splitFieldGroupHandle( String fieldGroupBo ){
        Assert.hasText( fieldGroupBo, I18nUtil.getI18nText( "common.fieldGroupNotBlank" ));
        fieldGroupBo = fieldGroupBo.replaceFirst( "FieldBO::", "" );
        String[] fieldParts = fieldGroupBo.split( "," );
        Assert.isTrue( fieldParts.length >= 2, I18nUtil.getI18nText( "common.fieldGroupBoNotValid", new String[]{ fieldGroupBo } ) );
        return fieldParts;
    }

    /**
     * 获取系统规则Handle
     *
     * @param site
     * @param ruleName
     * @return
     */
    public static String buildSystemRuleHanlde( String site, String ruleName ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( ruleName, I18nUtil.getI18nText( "common.systemRuleNotBlank" ));

        return  "SystemRuleBO:" + site + "," + ruleName;
    }

    /**
     * 获取样品信息Handle
     * @param site
     * @param sampleNo
     * @return
     *
     * */
    public  static String buildSampleHandle(String site,String sampleNo ){
        Assert.hasText(site,I18nUtil.getI18nText("common.siteNotBlank"));
        Assert.hasText(sampleNo,I18nUtil.getI18nText("qc.sample.sampleNotBlank"));
       // Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ) );

        return  "SampleBo:" + site + "," + sampleNo ;
    }

    /**
     * 获取工令Handle
     *
     * @param site
     * @param sfc
     * @return
     */
    public static String buildSFCHandle( String site, String sfc ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( sfc, I18nUtil.getI18nText( "common.sfcNotBlank" ) );

        return  "SFCBO:" + site + "," + sfc;
    }

    /**
     * 获取设备Handle
     *
     * @param site
     * @param resource
     * @return
     */
    public static String buildResourceHandle( String site, String resource ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ) );

        return "ResourceBO:" + site + "," + resource;
    }

    /**
     * 获取工序Handle
     *
     * @param site
     * @param operation
     * @return
     */
    public static String buildOperationHandleCurrRev( String site, String operation ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( operation, I18nUtil.getI18nText( "common.operationNotBlank" ) );

        return  "OperationBO:" + site + "," + operation + ",#";
    }

    /**
     * 获取物料*版本Handle
     *
     * @param site
     * @param item
     * @return
     */
    public static String buildItemHandleAllRev( String site, String item ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( item, I18nUtil.getI18nText( "common.itemNotBlank" ) );

        return  "ItemBO:" + site + "," + item + ",*";
    }

    /**
     * 物料Handle拆分
     *
     * @param itemBo
     * @return
     */
    public static String[] splitItemHandle( String itemBo ){
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ) );
        Assert.isTrue( itemBo.startsWith("ItemBO:"), I18nUtil.getI18nText( "common.itemBoNotValid", new String[]{ itemBo } ) );
        itemBo = itemBo.replaceFirst( "ItemBO:", "" );
        String[] itemParts = itemBo.split( "," );
        Assert.isTrue( itemParts.length >= 3, I18nUtil.getI18nText( "common.itemBoNotValid", new String[]{ itemBo } ) );
        return itemParts;
    }


    /**
     * 获取物料组Handle
     *
     * @param site
     * @param itemGroup
     * @return
     */
    public static String buildItemGroupHandle( String site, String itemGroup ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( itemGroup, I18nUtil.getI18nText( "common.itemGroupNotBlank" ) );

        return "ItemGroupBO:" + site + "," + itemGroup;
    }

    /**
     * 物料组Handle拆分
     *
     * @param itemGroupBo
     * @return
     */
    public static String[] splitItemGroupHandle( String itemGroupBo ){
        Assert.hasText( itemGroupBo, I18nUtil.getI18nText( "common.itemGroupNotBlank" ) );
        Assert.isTrue( itemGroupBo.startsWith("ItemGroupBO:"), I18nUtil.getI18nText( "common.itemGroupBoNotValid", new String[]{ itemGroupBo } ) );
        itemGroupBo = itemGroupBo.replaceFirst( "ItemGroupBO:", "" );
        String[] itemParts = itemGroupBo.split( "," );
        Assert.isTrue( itemParts.length == 2, I18nUtil.getI18nText( "common.itemGroupBoNotValid", new String[]{ itemGroupBo } ) );
        return itemParts;
    }

    /**
     * 获取研磨日志Handle
     *
     * @param site
     * @Param itemBo
     * @param date
     * @return
     */
    public static String buildGrindLogHandle( String site, String itemBo, Date date ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ));
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "GrindLogBO:" + site + "," + itemBo + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }

    /**
     * 获取作业记录Handle
     *
     * @param site
     * @param sfc
     * @param date
     * @return
     */
    public static String buildActivityLogHandle(String site, String sfc, String resource, Date date ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        //Assert.hasText( sfc, I18nUtil.getI18nText( "common.sfcNotBlank" ));
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ));
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        //sfc = sfc == null ? "" : sfc;
        //return "ActivityLogBO:" + site + "," + sfc + "," + resource + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
        return UUID.randomUUID().toString();
    }

    /**
     * 获取不合格代码Handle
     *
     * @param site
     * @param ncCode
     * @return
     */
    public static String buildNcCodeHandle( String site, String ncCode ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( ncCode, I18nUtil.getI18nText( "common.ncCodeNotBlank" ));

        return "NCCodeBO:" + site + "," + ncCode;
    }

    /**
     * 获取研磨检验Handle
     *
     * @param site
     * @param itemBo
     * @param date
     * @return
     */
    public static String buildGrindCheckHandle( String site, String itemBo, Date date ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ));
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "GrindCheckBO:" + site + "," + itemBo + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }

    /**
     * 获取研磨检验明细Handle
     *
     * @param grindCheckBo
     * @param ncCode
     * @return
     */
    public static String buildGrindCheckNcHandle( String grindCheckBo, String ncCode ){
        Assert.hasText( grindCheckBo, I18nUtil.getI18nText( "production.grind.grindCheckBoNotBlank" ));
        Assert.hasText( ncCode, I18nUtil.getI18nText( "common.ncCodeNotBlank" ));

        return "GrindCheckNcBO:" + grindCheckBo + "," + ncCode;
    }

    /**
     * 拆分工序Handle
     *
     * @param operationBo
     * @return
     */
    public static String[] splitOperationHandle( String operationBo ){
        if( StringUtils.isBlank( operationBo ) ){
            return new String[]{};
        }
        operationBo = operationBo.replaceFirst( "OperationBO:", "" );
        String[] itemParts = operationBo.split( "," );
        Assert.isTrue( itemParts.length >= 3, I18nUtil.getI18nText( "common.itemBoNotValid", new String[]{ operationBo } ) );
        return itemParts;
    }

    public static String[] splitResourceHandle( String resourceBo ){
        if( StringUtils.isBlank( resourceBo ) ){
            return new String[]{};
        }
        resourceBo = resourceBo.replaceFirst( "ResourceBO:", "" );
        String[] itemParts = resourceBo.split( "," );
        Assert.isTrue( itemParts.length >= 2, I18nUtil.getI18nText( "common.itemBoNotValid", new String[]{ resourceBo } ) );
        return itemParts;
    }


    /**
     * 获取不良数据Handle
     *
     * @param site
     * @param sfc
     * @param ncCode
     * @param date
     * @return
     */
    public static String buildNCDataHandle( ){
        /*Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        //Assert.hasText( sfc, I18nUtil.getI18nText( "common.sfcNotBlank" ) );
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ));
        Assert.hasText( ncCode, I18nUtil.getI18nText( "common.ncCodeNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        sfc = sfc == null ? "" : sfc;*/

        //return "NCDataBO:" + site + "," + sfc + "," + resource + "," + ncCode + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
        return UUID.randomUUID().toString();
    }

    /**
     * 获取人力出勤的Handle
     */
    public  static  String buildLaborAttendance(String site,Date workDate,
          String procedureBo,String itemBo,String dept,String shift){

        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.notNull( workDate, I18nUtil.getI18nText( "production.labor.workdate" ) );
        Assert.hasText(procedureBo,I18nUtil.getI18nText("production.sfc.procedureNotBlank"));
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ));
        Assert.hasText(dept,I18nUtil.getI18nText("production.labor.dept"));
        Assert.hasText( shift, I18nUtil.getI18nText( "production.labor.shift" ));


        return  "LaborAttendanceBo:"+site+","+DateUtil.format(workDate,"yyyy-MM-dd")
                +","+procedureBo+"," +itemBo+","+dept+","+shift;
    }


    /**
     * 获取本体扫码信息Handle
     *
     * @return
     */
    public static String buildCarrierScanLogHandle(  ){

        return UUID.randomUUID().toString();
    }

    /**
     * 获取本体绑定Handle
     *
     * @param site
     * @param carrier
     * @param date
     * @return
     */
    public static String buildCarrierBindHandle( String site, String carrier, String itemBo, Date date ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( carrier, I18nUtil.getI18nText( "common.carrierNotBlank" ) );
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "CarrierBindBO:" + site + "," + carrier + "," + itemBo + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }

    /**
     * 获取工令批次过站记录Handle
     *
     * @return
     */
    public static String buildSfcBatchPassLogHandle(){

        return UUID.randomUUID().toString();
    }

    /**
     * 获取客户记录Handle
     *
     * @param site
     * @param customer
     * @return
     */
    public  static String buildCustomerHandle(String site,String customer){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( customer, I18nUtil.getI18nText( "common.customerNotBlank" ) );
        return  "CustomerBO:" + site + "," + customer;
    }
    /**
     * 获取AGV上传信息记录Handle
     *
     * @return
     */
    public static String buildAgvReqLogHandle(){

        return UUID.randomUUID().toString();
    }

    /**
     * 获取cnc上传信息记录Handle
     *
     * @return
     */
    public static String buildCncReqLogHandle(){
        /*Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ) );
        Assert.hasText( carrier, I18nUtil.getI18nText( "common.carrierNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );*/

        //return "CncReqLogBO" + site + "," + resource + "," + carrier + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
        return UUID.randomUUID().toString();
    }

    /**
     * 获取刀具使用寿命Handle
     *
     * @param site
     * @param resource
     * @param toolLoc
     * @param date
     * @return
     */
    public static String buildToolUsageLogHandle( String site, String resource, String toolLoc, Date date ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ) );
        Assert.hasText( toolLoc, I18nUtil.getI18nText( "common.toolLocNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "ToolUsageLogBO:" + site + "," + resource + "," + toolLoc + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }
   /**
   * 获取领料单据记录表Handle
    *
    * @param site
    * @param bill
    * @return
   */
    public static String buildPickingBillLogHandle( String site,String bill ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( bill, I18nUtil.getI18nText( "production.picking.Bill" ) );

        return "PickingBillLogBO:" + site + "," + bill ;
    }
    /**
     * 获取领料清单明细表Handle
     *
     * @param site
     * @param bill
     * @param item
     * @return
     */
    public static  String buildPickingBomHandle( String site,String bill,String item , Date date){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( bill, I18nUtil.getI18nText( "production.picking.Bill" ) );
        Assert.hasText( item, I18nUtil.getI18nText( "common.itemNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "PickingBomBO:" + site + "," + bill + "," + item + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }

    /**
     * 获取nc_code_def Handle
     *
     * @param site
     * @param ncCode
     * @return
     */
    public static String buildNCCodeDefHandle( String site, String ncCode ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( ncCode, I18nUtil.getI18nText( "common.ncCodeNotBlank" ) );

        return "NCCodeDefBO:NCCodeBO:" + site + "," + ncCode;
    }
   /**
   * 获取 ToolBill Handle
   * @param  site
   * @param  toolBillRevision
   * @param  cncType
   * @return
   */
    public static String builToolBillHandle( String site, String toolBillRevision,String cncType ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( toolBillRevision, I18nUtil.getI18nText( "production.cnctool.toolBillRevision" ) );
        Assert.hasText( cncType ,I18nUtil.getI18nText("production.cutter.cncType" ) );

        return "ToolBillBO:"+ site + "," + cncType + "," + toolBillRevision;
    }

    /**
    * 获取 ToolBillItem Handle
    * @param toolBillBo
    * @param toolLoc
     *
    * @return
    * */
    public  static  String builToolBillItemHandle( String toolBillBo,String toolLoc ){
        Assert.hasText( toolBillBo, I18nUtil.getI18nText( "production.cnctool.toolBillRevision" ) );
        Assert.hasText( toolLoc, I18nUtil.getI18nText( "production.tool.toolLoc" ) );


        return "ToolBillItemBO:"+ toolBillBo + "," + toolLoc;
    }

    /**
    * 获取ToolBreakHandle
    *
    * @return
    * */
    public  static String buildToolBreakHandle(  ){

        return  UUID.randomUUID().toString() ;
    }

    /**
     * 获取包装记录Handle
     *
     * @param itemBo
     * @param resource
     * @param date
     * @return
     */
    public static String buildPackLogHandle( String itemBo, String resource, Date date ){
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ) );
        Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );

        return "PackLogBO:" + itemBo + "," + resource + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
    }

    /**
     * 获取容器Handle
     *
     * @param site
     * @param container
     * @return
     */
    public static String buildContainerHandle( String site, String container ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( container, I18nUtil.getI18nText( "common.containerNotBlank" ) );

        return "ContainerBO:" + site + "," + container;
    }

    /**
     * 获取生产班次日期类型Handle
     *
     * @param site
     * @param productionDayType
     * @return
     */
    public static String buildProductionDayType( String site, String productionDayType ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( productionDayType, I18nUtil.getI18nText( "common.productionDayTypeNotBlank" ) );

        return "ProductionDayTypeBO:" + site + "," + productionDayType;
    }


    /**
    * 获取目检、三次元Handle
    *
    * @param  site
    * @param  taskId
    *
    * @return
     * */
    public  static String buildQcCheckHandle( String site , String taskId ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( taskId, I18nUtil.getI18nText("common.taskIdNotBlank") );

        return  "QcCheckBO:" + site + "," + taskId;
    }

    /**
     * 获取目检、三次元明细Handle
     *
     * @return
     * */
    public  static String buildQcCheckNcHandle( ){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取目检/三次元明细测量数据Handle
     *
     * @return
     */
    public  static String buildQcCheckFaiHandle( ){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取三次元检测失败数据Handle
     *
     * @return
     */
    public  static String buildQcCheckFaiFailHandle( ){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取点检任务Handle
     *
     * @param  site
     * @param  taskId
     *
     * @return
     * */
    public  static String buildSysTaskHandle( String site , String taskId ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( taskId, I18nUtil.getI18nText("common.taskIdNotBlank") );

        return  "SysTaskBO:" + site + "," + taskId;

    }

    /**
     * 获取FQC检验记录Handle
     *
     * @param itemBo
     * @param resource
     * @param date
     * @return
     */
    public static String buildFqcCheckHandle(){
        /*Assert.hasText( resource, I18nUtil.getI18nText( "common.resourceNotBlank" ) );
        Assert.hasText( itemBo, I18nUtil.getI18nText( "common.itemNotBlank" ) );
        Assert.notNull( date, I18nUtil.getI18nText( "common.dateNotNull" ) );*/

        //return "FqcCheckBO:" + itemBo + "," + resource + "," + DateUtil.format( date, "yyyy-MM-dd HH:mm:ss.SSS" );
        return UUID.randomUUID().toString();
    }

    /**
     * 获取FQC检验记录批次明细记录Handle
     *
     * @param fqcCheckBo
     * @param containerNumber
     * @return
     */
    public static String buildFqcCheckBoxHandle(){

        return UUID.randomUUID().toString();
    }

    /**
     * 获取FQC检验记录不良明细记录Handle
     *
     * @param fqcCheckBo
     * @param ncCode
     * @return
     */
    public static String buildFqcCheckNcHandle(){

        return UUID.randomUUID().toString();
    }

    /**
     * 获取存储地点Handle
     *
     * @param site
     * @param storageLocation
     * @return
     */
    public static String buildStorageLocationHandle( String site, String storageLocation ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( storageLocation, I18nUtil.getI18nText( "common.storageLocationNotBlank" ) );

        return "StorageLocationBO:" + site + "," + storageLocation;
    }

    /**
     * 获取入库记录表Handle
     *
     * @return
     */
    public static String buildGoodsReceiptLogHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 拆分工艺路线Handle
     *
     * @param routerBo
     * @return
     */
    public static String[] splitRouterHandle( String routerBo ){
        Assert.hasText( routerBo, I18nUtil.getI18nText( "common.routerBoNotBlank" ) );
        Assert.isTrue( routerBo.startsWith("RouterBO:"), I18nUtil.getI18nText( "common.routerBoNotValid", new String[]{ routerBo } ) );
        routerBo = routerBo.replaceFirst( "RouterBO:", "" );
        String[] routerParts = routerBo.split( "," );
        Assert.isTrue( routerParts.length >= 4, I18nUtil.getI18nText( "common.routerBoNotValid", new String[]{ routerBo } ) );
        return routerParts;
    }

    /**
     * 获取用户Handle
     *
     * @param site
     * @param userId
     * @return
     */
    public static String buildUserHandle( String site, String userId ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( userId, I18nUtil.getI18nText( "common.userIdNotBlank" ) );

        return "UserBO:" + site + "," + userId;
    }

    /**
     * 获取作业Handle
     *
     * @param activityId
     * @return
     */
    public static String buildActivityHandle( String activityId ){
        Assert.hasText( activityId, I18nUtil.getI18nText("common.ActivityNotBlank" ) );

        return "ActivityBO:" + activityId;
    }

    /**
     * 获取资源类型Handle
     *
     * @param site
     * @param resourceType
     * @return
     */
    public static String buildResourceTypeHandle( String site, String resourceType ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( resourceType, I18nUtil.getI18nText( "common.resourceTypeNotBlank" ));

        return "ResourceTypeBO:" + site + "," + resourceType;
    }

    /**
     * 获取不合格代码组Handle
     *
     * @param site
     * @param ncGroup
     * @return
     */
    public static String buildNcGroupHandle( String site, String ncGroup ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( ncGroup, I18nUtil.getI18nText( "common.ncGroupNotBlank" ) );

        return "NCGroupBO:" + site + "," + ncGroup;
    }

    /**
     * 拆分容器Handle
     *
     * @param containerBo
     * @return
     */
    public static String[] splitContainerHandle( String containerBo ){
        Assert.hasText( containerBo, I18nUtil.getI18nText( "common.containerNotBlank" ) );
        containerBo = containerBo.replaceFirst( "ContainerBO:", "" );
        String[] containerParts = containerBo.split( "," );
        Assert.isTrue( containerParts.length >= 2, I18nUtil.getI18nText( "common.containerBoNotValid", new String[]{ containerBo } ) );
        return containerParts;
    }

    /**
     * 刀具记录表Handle
     *
     * @param toolType
     * @param site
     * @return
     */
    public static String buildToolHandle(String site , String toolType ){
        Assert.hasText( toolType, I18nUtil.getI18nText( "production.tool.toolType" ) );
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );

        return "ToolBo:"+ site +","+toolType;
    }

    /**
     * 获取设备状态时间日志Handle
     *
     * @return
     */
    public static String buildResourceTimeLogHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取设备状态时间日志Handle
     *
     * @return
     */
    public static String buildTranshipInfraHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取工作中心Handle
     *
     * @param site
     * @param workCenter
     * @return
     */
    public static String buildWorkCenterHandle( String site, String workCenter ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ) );
        Assert.hasText( workCenter, I18nUtil.getI18nText( "common.workCenterNotBlank" ) );

        return "WorkCenterBO:" + site + "," + workCenter;
    }

    /**
     * 拆分工作中心Handle
     *
     * @param workCenerBo
     * @return
     */
    public static String[] splitWorkCenterHandle( String workCenerBo ){
        Assert.hasText( workCenerBo, I18nUtil.getI18nText( "common.workCenterNotBlank" ) );
        workCenerBo = workCenerBo.replaceFirst( "WorkCenterBO:", "" );
        String[] workCenterParts = workCenerBo.split( "," );
        Assert.isTrue( workCenterParts.length >= 2, I18nUtil.getI18nText( "common.workCenterBoNotValid", new String[]{ workCenerBo } ) );
        return workCenterParts;
    }

    /**
     * 获取机种程式Handle
     *
     * @param site
     * @param machineType
     * @param cncType
     * @param prgmCode
     * @param revision
     * @param subSeq
     * @return
     */
    public static String buildCncProgramHandle( String site, String machineType, String cncType, String prgmCode, String revision, String subSeq ){
        /**检查机种*/
        Assert.hasText( machineType, I18nUtil.getI18nText("common.machineTypeNotBlank") );
        /**检查夹位*/
        Assert.hasText( cncType, I18nUtil.getI18nText("common.machineTypeNotBlank") );
        /**检查程式编号*/
        Assert.hasText( prgmCode, I18nUtil.getI18nText("production.cncProgram.prgmCodeNotBlank") );
        /**检查版本*/
        Assert.hasText( revision, I18nUtil.getI18nText("production.cncProgram.revisionNotBlank") );
        /**检查版次*/
        Assert.hasText( subSeq, I18nUtil.getI18nText("production.cncProgram.subSeqNotBlank") );

        return "CncProgramBO:" + site + "," + machineType + "," + cncType + "," + prgmCode + "," + revision + "," + subSeq;
    }

    /**
     * 获取机种程式明细Handle
     *
     * @param cncProgramBo
     * @param prgmCode
     * @return
     */
    public static String buildCncProgramItemHandle( String cncProgramBo, String prgmCode ){
        /**检查程式编号*/
        Assert.hasText( cncProgramBo, I18nUtil.getI18nText("production.cncProgram.prgmCodeNotBlank") );
        /**检查程式编号*/
        Assert.hasText( prgmCode, I18nUtil.getI18nText("production.cncProgram.prgmCodeNotBlank") );

        return "CncProgramItemBO:" + cncProgramBo + "," + prgmCode;
    }

    /**
     * 拆分刀具清单Handle
     *
     * @param toolBillBo
     * @return
     */
    public static String[] splitToolBillHandle( String toolBillBo ){
        Assert.hasText( toolBillBo, I18nUtil.getI18nText( "production.cnctool.toolBillRevision" ) );
        toolBillBo = toolBillBo.replaceFirst( "ToolBillBO:", "" );
        String[] toolBillParts = toolBillBo.split( "," );
        Assert.isTrue( toolBillParts.length >= 3, I18nUtil.getI18nText( "common.toolBillBoNotValid", new String[]{ toolBillBo } ) );
        return toolBillParts;
    }

    /**
     * 获取全检报警记录表Handle
     *
     * @return
     */
    public static String buildInspectAlarmLogHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取客诉记录表Handle
     *
     * @return
     */
    public static String buildCustCmplnHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取设备维修记录Handle
     *
     * @return
     */
    public static String buildResourceRepairLogHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取样品/检具点检记录表Handle
     *
     * @return
     */
    public static String buildPointCheckHandle(){
        return UUID.randomUUID().toString();
    }

    /**
     * 获取工具组Handle
     *
     * @param site
     * @param group
     * @return
     */
    public static String buildToolGroupHandle( String site, String group ){
        Assert.hasText( site, I18nUtil.getI18nText( "common.siteNotBlank" ));
        Assert.hasText( group, I18nUtil.getI18nText( "common.toolGroupNotBlank" ));

        return "ToolGroupBO:" + site + "," + group;
    }

    /**
     * 获取程式上传下载CNC记录Handle
     *
     * @return
     */
    public static String buildProgramActionLogHandle(){
        return UUID.randomUUID().toString();
    }
}

